import * as React from 'react';
import classNames from 'classnames';

export interface PagerProps {
	children?: React.ReactNode;
	//className?: string;
	rootPrefixCls?: string;
	active?: boolean;
	page?: number;

	onClick?: (page: number) => void;
}

const Pager: React.FC<PagerProps> = props => {
	const prefixCls = `${props.rootPrefixCls}-item`;
	const classString = classNames(prefixCls, `${prefixCls}-${props.page}`, {
		[`${prefixCls}-active`]: props.active,
		[`${prefixCls}-disabled`]: !props.page,
		//[props.className]: !!props.className,
	});
	const title = props.page + '';

	const handleClick = () => {
		props.onClick && props.onClick(props.page || 1);
	}

	return (<li 
		className={classString} 
		key={props.page}
		onClick={handleClick}
		title={title}>
		<a rel="nofollow">{props.page}</a>
	</li>);
}

export default Pager;